<?php

// +----------------------------------------------------------------------
// | TAODUDU.COM  [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.taodudu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: ubten <462193409@qq.com> http://www.ubten.com/
// +----------------------------------------------------------------------

namespace Home\Controller;
use Think\Controller;
class GuangController extends Controller {
    //put your code here
    
    public function userOrder(){
        $map['order_state'] = array('EGT',20);
        //$map['user_id'] = 16;
        $order = M('order')->where($map)->select();
        foreach ($order as $key => $value) {
            $where['user_id'] = $value['user_id'];
            M('users')->where($where)->setInc('user_points',$value['goods_amount']);
            M('users')->where($where)->setInc('user_orders',1);
            p($key);
        }
        exit;
    }
    
    
    public function addSale(){
        
        $map['order_state'] = array('EGT',20);
        //$map['user_id'] = 16;
        $order = M('order')->where($map)->select();
        foreach ($order as $key => $value) {
            $where['order_id'] = $value['order_id'];
            $goods = M('order_goods')->field('goods_id,goods_num')->where($where)->select();

            foreach ($goods as $k => $v) {
                $maps['goods_id'] = $v['goods_id'];
                $re = M('goods')->where($maps)->setInc('goods_realsale', $v['goods_num']);
                p($re);
            }
        
        }
        exit;
    }
    
}
